package com.hezhi.project.module.machineRecord.service;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.hezhi.common.utils.StringUtils;
import com.hezhi.project.module.machineRecord.mapper.MachineRecordMapper;
import com.hezhi.project.module.machineRecord.domain.MachineRecord;
import com.hezhi.project.module.machineRecord.service.IMachineRecordService;
import com.hezhi.common.support.Convert;

/**
 * 闸机下发记录 服务层实现
 * 
 * @author hezhi
 * @date 2018-08-10
 */
@Service
public class MachineRecordServiceImpl implements IMachineRecordService 
{
	@Autowired
	private MachineRecordMapper machineRecordMapper;

	/**
     * 查询闸机下发记录信息
     * 
     * @param id 闸机下发记录ID
     * @return 闸机下发记录信息
     */
    @Override
	public MachineRecord selectMachineRecordById(Integer id)
	{
	    return machineRecordMapper.selectMachineRecordById(id);
	}
	
	/**
     * 查询闸机下发记录列表
     * 
     * @param machineRecord 闸机下发记录信息
     * @return 闸机下发记录集合
     */
	@Override
	public List<MachineRecord> selectMachineRecordList(MachineRecord machineRecord)
	{
	    return machineRecordMapper.selectMachineRecordList(machineRecord);
	}
	
    /**
     * 新增闸机下发记录
     * 
     * @param machineRecord 闸机下发记录信息
     * @return 结果
     */
	@Override
	public int insertMachineRecord(MachineRecord machineRecord)
	{
	    return machineRecordMapper.insertMachineRecord(machineRecord);
	}
	
	/**
     * 修改闸机下发记录
     * 
     * @param machineRecord 闸机下发记录信息
     * @return 结果
     */
	@Override
	public int updateMachineRecord(MachineRecord machineRecord)
	{
	    return machineRecordMapper.updateMachineRecord(machineRecord);
	}
	
	/**
     * 保存闸机下发记录
     * 
     * @param machineRecord 闸机下发记录信息
     * @return 结果
     */
	@Override
	public int saveMachineRecord(MachineRecord machineRecord)
	{
	    Integer id = machineRecord.getId();
		int rows = 0;
		if (StringUtils.isNotNull(id))
        {
		    rows = machineRecordMapper.updateMachineRecord(machineRecord);
		}
		else
        {
		    rows = machineRecordMapper.insertMachineRecord(machineRecord);
		}
		return rows;
	}
	
	/**
     * 删除闸机下发记录对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
	@Override
	public int deleteMachineRecordByIds(String ids)
	{
		return machineRecordMapper.deleteMachineRecordByIds(Convert.toIntArray(ids));
	}
	
}
